package main

import (
	"fmt"
	"sort"
)

type User struct {
	Id       int
	Name     string
	Password string
}

func main() {
	users := []User{
		{22, "s1", "password1"},
		{32, "s1", "password23"},
		{21, "s1", "password12"},
		{43, "s1", "password65"},
		{12, "s1", "password134"},
	}

	sort.Slice(users, func(i, j int) bool {
		return users[i].Id < users[j].Id
	})
	fmt.Println(users)
	// 切片排序
	name := []int{1, 4, 22, 11, 54, 22, 34, 3}
	sort.Slice(name, func(i, j int) bool {
		return name[i] < name[j]
	})
	fmt.Println(name)
}
